function* walk(str) {
  let s = "";
  for (let c of str) {
    if (c === "-") {
      yield Number(s);
      s = "";
    } else {
      s += c;
    }
    console.log("s", s);
  }
  if (s) {
    yield Number(s);
    console.log("s1", s);
  }
}

const iter = walk("1-2-3-4-5");

console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
